package com.iot08.common.utils;

import java.util.Random;

/**
 * @version 1.0
 * @Description:
 * @time: 2020/11/4 14:14
 * @author: Rock
 */
public class RandomUtil {

    /**
     * 获取区间内的随机数字符串
     *
     * @param min
     * @param max
     * @time: 2020/11/4 14:15
     * @author: Rock
     * @version 1.0
     */
    public static String getRandom(int min, int max) {
        Random random = new Random();
        int s = random.nextInt(max) % (max - min + 1) + min;
        return String.valueOf(s);
    }

    /**
     * @param min
     * @param max
     * @time: 2021/1/20 18:50
     * @author: Rock
     * @version 1.0
     */
    public static int getRandomInt(int min, int max) {
        Random random = new Random();
        return random.nextInt(max) % (max - min + 1) + min;
    }

    /**
     * 获取字母和数字组合的随机字符串
     *
     * @param len
     * @time: 2020/10/23 18:15
     * @author: Rock
     * @version 1.0
     */
    public static String getRandomStr(int len) {
        String base = "abcdefghijklnmopqrstuvwsyz1234567890";
        Random ra = new Random();
        String result = "";
        for (int i = 0; i < len; i++) {
            result += base.charAt(ra.nextInt(36));
        }
        return result;
    }

}
